package com.example.schoolhospitalsystem;



import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class CreateMedicalRecordActivity extends AppCompatActivity {

    private EditText etPatientId, etSymptoms, etDiagnosis, etPrescription;
    private Button btnCreateRecord;
    private String doctorId;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_create_medical_record);

        // 获取医生ID
        Intent intent = getIntent();
        doctorId = intent.getStringExtra("doctorId");

        etPatientId = findViewById(R.id.et_patient_id);
        etSymptoms = findViewById(R.id.et_symptoms);
        etDiagnosis = findViewById(R.id.et_diagnosis);
        etPrescription = findViewById(R.id.et_prescription);
        btnCreateRecord = findViewById(R.id.btn_create_record);

        // 创建病历按钮点击事件
        btnCreateRecord.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String patientId = etPatientId.getText().toString().trim();
                String symptoms = etSymptoms.getText().toString().trim();
                String diagnosis = etDiagnosis.getText().toString().trim();
                String prescription = etPrescription.getText().toString().trim();

                if (patientId.isEmpty() || symptoms.isEmpty() || diagnosis.isEmpty() || prescription.isEmpty()) {
                    Toast.makeText(CreateMedicalRecordActivity.this, "请填写所有必填信息", Toast.LENGTH_SHORT).show();
                    return;
                }

                // 创建病历
                if (createMedicalRecord(doctorId, patientId, symptoms, diagnosis, prescription)) {
                    Toast.makeText(CreateMedicalRecordActivity.this, "病历创建成功", Toast.LENGTH_SHORT).show();
                    finish();
                } else {
                    Toast.makeText(CreateMedicalRecordActivity.this, "病历创建失败", Toast.LENGTH_SHORT).show();
                }
            }
        });
    }

    private boolean createMedicalRecord(String doctorId, String patientId, String symptoms, String diagnosis, String prescription) {
        // 这里应该连接数据库创建病历记录
        // 简化示例，直接返回创建成功
        return true;
    }
}